<template>
  <div class="query">
    <div class="check">
      <div class="c_left">条件搜索栏</div>
      <div class="c_right">
        <div class="clear">
          <div class="fl">
            <span class="c_tip">请填写病区</span>
            <el-input v-model="formInfo.Wardcode" type="text" placeholder="请填写病区" />
          </div>
          <div class="fl">
            <span class="c_tip">患者姓名</span>
            <el-input v-model="formInfo.Patient_name" type="text" placeholder="请输入患者姓名" />
          </div>
          <div class="fl">
            <span class="c_tip">患者号</span>
            <el-input v-model="formInfo.Patient_id" type="text" placeholder="请输入患者号" />
          </div>
        </div>
        <div class="fl">
          <span class="c_tip">入院时间</span>
          <el-date-picker
            v-model="formInfo.Startdate"
            type="date"
            placeholder="选择日期"
            format="yyyy/MM/dd"
            value-format="yyyy/MM/dd"
          />
          <span>至</span>
          <el-date-picker
            v-model="formInfo.Enddate"
            type="date"
            placeholder="选择日期"
            format="yyyy/MM/dd"
            value-format="yyyy/MM/dd"
          />
        </div>
        <div class="fl">
          <span class="c_tip" />
          <el-button type="primary" class="btn_clear" @click="getDeptEvaluationDataList">查询</el-button>
        </div>
      </div>
    </div>
    <div class="list_tip clear" />
    <div class="table_box">
      <Bluetable :t-head="tHead" :t-data="drugEvaluationDataList" @operateClick="operateClick" />
      <pagination
        :total="query.total"
        :page.sync="query.pagenum"
        :limit.sync="query.pagesize"
        @pagination="getList"
      />
    </div>
    <!--    弹窗-->
    <el-dialog
      title="药学评估表"
      :visible.sync="childOpen"
      width="1350px"
    >
      <div class="wrapper">
        <el-scrollbar style="width:1300px;height:600px">
          <div class="basics">
            <card>
              <div slot="cardHeader">基本资料</div>
              <div slot="cardBody">
                <div class="infoline">
                  <div class="fl">
                    <div class="c_tip">姓名:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.PatientName }}</div>
                  </div>
                  <div class="fl">
                    <div class="c_tip">性别:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.Sex }}</div>
                  </div>
                  <div class="fl">
                    <div class="c_tip">年龄:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.Age }}</div>
                  </div>
                  <div class="fl" />
                </div>
                <div class="infoline">
                  <div class="fl">
                    <div class="c_tip">床号:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.BedNo }}</div>
                  </div>
                  <div class="fl">
                    <div class="c_tip">住院号:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.InpNo }}</div>
                  </div>
                  <div class="fl">
                    <div class="c_tip">入院时间:</div>
                    <div class="c_text">{{ patientInfo.InpPatData.StartDate }}</div>
                  </div>
                  <!--                  布局使用-->
                  <div class="fl" />
                </div>
              </div>
            </card>
          </div>
          <div class="condition">
            <card>
              <div slot="cardHeader">入院情况</div>
              <div slot="cardBody">
                <div class="line">
                  <div class="line-title">意识:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Concept">
                      <el-radio :label="'0'">清醒</el-radio>
                      <el-radio :label="'1'">嗜睡</el-radio>
                      <el-radio :label="'2'">恍惚</el-radio>
                      <el-radio :label="'3'">昏迷</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">营养:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Nutrition">
                      <el-radio :label="'0'">良好</el-radio>
                      <el-radio :label="'1'">一般</el-radio>
                      <el-radio :label="'2'">消瘦</el-radio>
                      <el-radio :label="'3'">恶病质</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">听力:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Hearing">
                      <el-radio :label="'0'">清晰</el-radio>
                      <el-radio :label="'1'">重听</el-radio>
                      <el-radio :label="'2'">失聪</el-radio>
                      <el-radio :label="'3'">助听器</el-radio>
                      <el-radio :label="'4'">其他</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">语言:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Language">
                      <el-radio :label="'0'">正常</el-radio>
                      <el-radio :label="'1'">失语</el-radio>
                      <el-radio :label="'2'">含糊不清</el-radio>
                      <el-radio :label="'3'">手势语</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">基本膳食:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Basicdiet">
                      <el-radio :label="'0'">普食</el-radio>
                      <el-radio :label="'1'">半流</el-radio>
                      <el-radio :label="'2'">流质</el-radio>
                      <el-radio :label="'3'">禁食</el-radio>
                      <el-radio :label="'4'">其他</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">自理能力:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.SelfCareability">
                      <el-radio :label="'0'">完全自理</el-radio>
                      <el-radio :label="'1'">部分依赖</el-radio>
                      <el-radio :label="'2'">完全依赖(进食、穿衣、淋浴、入厕)</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">嗜好:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Hobby">
                      <el-radio :label="'0'">无</el-radio>
                      <el-radio :label="'1'">酒</el-radio>
                      <el-radio :label="'2'">烟</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-input">
                    <div class="input-title">禁忌:</div>
                    <div class="line-content">
                      <el-input v-model="patientInfo.DrugeValuationPlan.Taboo" type="text" placeholder="请填写禁忌" />
                    </div>
                  </div>
                  <div class="line-input">
                    <div class="input-title">偏好:</div>
                    <div class="line-content">
                      <el-input v-model="patientInfo.DrugeValuationPlan.Preference" type="text" placeholder="请填写偏好" />
                    </div>
                  </div>
                  <div class="line-input">
                    <div class="input-title">治疗饮食:</div>
                    <div class="line-content">
                      <el-input v-model="patientInfo.DrugeValuationPlan.TheraPeuticdiet" type="text" placeholder="请填写治疗饮食	" />
                    </div>
                  </div>
                </div>

              </div>
            </card>
          </div>
          <div class="previous">
            <card>
              <div slot="cardHeader">既往用药情况</div>
              <div slot="cardBody">
                <div class="line">
                  <div class="line-title">适应症:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Indication">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">用法用量:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Dosage">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">注意事项:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Attention">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">不良反应:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.UnUsualReaction">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">自我药疗效果:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.SelfMedication">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">用药依从性评价:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.DrugCompliance">
                      <el-radio :label="'0'">好</el-radio>
                      <el-radio :label="'1'">较好</el-radio>
                      <el-radio :label="'2'">一般</el-radio>
                      <el-radio :label="'3'">较差</el-radio>
                      <el-radio :label="'4'">不理解</el-radio>
                    </el-radio-group>
                  </div>
                </div>

              </div>
            </card>
          </div>
          <div class="allergy">
            <card>
              <div slot="cardHeader">过敏史</div>
              <div slot="cardBody">
                <div class="line">
                  <div class="line-title">过敏史:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.Allergyhistory">
                      <el-radio :label="'0'">有</el-radio>
                      <el-radio :label="'1'">无</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-title">处理措施及结果:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.TreatMentmeasures">
                      <el-radio :label="'0'">未停药</el-radio>
                      <el-radio :label="'1'">停药后缓解</el-radio>
                      <el-radio :label="'2'">对症治疗后缓解</el-radio>
                      <el-radio :label="'3'">对症治疗后未缓解</el-radio>
                      <el-radio :label="'4'">未再次使用</el-radio>
                      <el-radio :label="'5'">再次使用又出现</el-radio>
                    </el-radio-group>
                  </div>
                </div>
                <div class="line">
                  <div class="line-input-long">
                    <div class="input-title-long">怀疑药物/食物:</div>
                    <div class="line-content">
                      <el-input v-model="patientInfo.DrugeValuationPlan.Suspecteddrugs" type="text" placeholder="请填写怀疑药物/食物" />
                    </div>
                  </div>
                </div>
                <div class="line">
                  <div class="line-input-long">
                    <div class="input-title-long">相关分析:</div>
                    <div class="line-content">
                      <el-input v-model="patientInfo.DrugeValuationPlan.Correlationanalysis" type="text" placeholder="请填写相关分析" />
                    </div>
                  </div>
                </div>
                <div class="line">
                  <div class="line-input-long">
                    <div class="input-title ">主要临床症状:</div>
                    <div class="line-content" />
                  </div>
                </div>
              </div>
            </card>
          </div>
          <div class="perceive">
            <card>
              <div slot="cardHeader">疾病认识</div>
              <div slot="cardBody">
                <div class="line">
                  <div class="line-title">疾病认识:</div>
                  <div class="line-content">
                    <el-radio-group v-model="patientInfo.DrugeValuationPlan.DiseaseRecognition">
                      <el-radio :label="'0'">完全</el-radio>
                      <el-radio :label="'1'">部分</el-radio>
                      <el-radio :label="'2'">不认识</el-radio>
                      <el-radio :label="'3'">未被告知</el-radio>
                    </el-radio-group>
                  </div>
                </div>
              </div>
            </card>
          </div>

        </el-scrollbar>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog">取 消</el-button>
        <el-button type="primary" @click="saveEvaluationInfo">保 存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Card from '../../../prc/childComps/card/Card'
import { GetDeptEvaluationDataList, CurrencyEvaluationDetail, SaveEvaluationInfo } from '@/api/cpw'
export default {
  components: {
    Card
  },
  data() {
    return {
      // 查询信息
      formInfo: {
        // 开始时间
        Startdate: '',
        // 结束时间
        Enddate: '',
        // 病区
        Wardcode: '',
        // 患者姓名
        Patient_name: '',
        // 患者号
        Patient_id: ''
      },
      // 查询列表分页参数
      query: {
        // 第n页
        pagenum: 1,
        // 每页多少条
        pagesize: 10,
        // 总条数
        total: 0
      },
      // 通用评估病人列表
      drugEvaluationDataList: {},
      // 获取单个病人的评估信息查询数据
      queryInfo: {
        patient_id: '',
        visit_id: '',
        inp_no: ''
      },
      // 查询到的信息
      patientInfo: {
        DrugeValuationPlan: {
          Concept: '',
          Nutrition: '',
          Hearing: '',
          Language: '',
          Basicdiet: '',
          SelfCareability: '',
          Hobby: '',
          Taboo: '',
          Preference: '',
          TheraPeuticdiet: '',
          Indication: '',
          Dosage: '',
          Attention: '',
          UnUsualReaction: '',
          SelfMedication: '',
          DrugCompliance: '',
          Allergyhistory: '',
          TreatMentmeasures: '',
          Suspecteddrugs: '',
          Correlationanalysis: '',
          DiseaseRecognition: ''
        },
        InpPatData: {}
      },
      radio: '6',
      tHead: [
        {
          operate: ['药学评估量表'],
          label: '操作',
          link: true
        },
        {
          prop: 'patient_name',
          label: '患者姓名'
        },
        {
          prop: 'sex',
          label: '性别'
        },
        {
          prop: 'startdate',
          label: '入院时间'
        },
        {
          prop: 'wardcode',
          label: '病区'
        },
        {
          prop: 'deptname',
          label: '科室'
        },
        {
          prop: 'disname',
          label: '诊断'
        }
      ],
      // 是否显示
      childOpen: false
    }
  },
  methods: {
    // api
    // 获取通用评估病人列表
    async getDeptEvaluationDataList() {
      var tempObj = JSON.parse(JSON.stringify(this.formInfo))
      for (var key in tempObj) {
        if (tempObj[key] === '') {
          delete tempObj[key]
        }
      }
      await GetDeptEvaluationDataList({
        json: tempObj,
        pagenum: this.query.pagenum,
        pagesize: this.query.pagesize
      }).then(res => {
        this.drugEvaluationDataList = res.rows
        this.query.total = res.records
      }).catch(err => {
        console.log(err)
      })
    },
    // 获取单个病人的评估信息
    async currencyEvaluationDetail() {
      await CurrencyEvaluationDetail({
        patient_id: this.queryInfo.patient_id,
        visit_id: this.queryInfo.visit_id
      }).then(res => {
        console.log(res)
        this.patientInfo.InpPatData = res.InpPatData[0]
        if (res.DrugeValuationPlan.length > 0) {
          this.patientInfo.DrugeValuationPlan = res.DrugeValuationPlan[0]
        } else {
          this.patientInfo.DrugeValuationPlan = {}
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 分页数据改变
    async getList(type) {
      this.query.pagenum = type.page
      this.query.pagesize = type.limit
      await this.getDeptEvaluationDataList()
    },
    // 查询个人信息
    operateClick(val, row) {
      this.queryInfo.patient_id = row.patient_id
      this.queryInfo.visit_id = row.visit_id
      this.queryInfo.inp_no = row.inp_no
      this.currencyEvaluationDetail()
      this.childOpen = true
    },
    // 保存个人信息
    async saveEvaluationInfo() {
      await SaveEvaluationInfo({
        json: {
          PATIENT_ID: this.queryInfo.patient_id,
          VISIT_ID: this.queryInfo.visit_id,
          INP_NO: this.queryInfo.inp_no,
          CONCEPT: this.patientInfo.DrugeValuationPlan.Concept,
          NUTRITION: this.patientInfo.DrugeValuationPlan.Nutrition,
          HEARING: this.patientInfo.DrugeValuationPlan.Hearing,
          LANGUAGE: this.patientInfo.DrugeValuationPlan.Language,
          BASICDIET: this.patientInfo.DrugeValuationPlan.Basicdiet,
          TABOO: this.patientInfo.DrugeValuationPlan.Taboo,
          PREFERENCE: this.patientInfo.DrugeValuationPlan.Preference,
          THERAPEUTICDIET: this.patientInfo.DrugeValuationPlan.TheraPeuticdiet,
          SELFCAREABILITY: this.patientInfo.DrugeValuationPlan.SelfCareability,
          HOBBY: this.patientInfo.DrugeValuationPlan.Hobby,
          INDICATION: this.patientInfo.DrugeValuationPlan.Indication,
          DOSAGE: this.patientInfo.DrugeValuationPlan.Dosage,
          ATTENTION: this.patientInfo.DrugeValuationPlan.Attention,
          UNUSUALREACTION: this.patientInfo.DrugeValuationPlan.UnUsualReaction,
          SELFMEDICATION: this.patientInfo.DrugeValuationPlan.SelfMedication,
          DRUGCOMPLIANCE: this.patientInfo.DrugeValuationPlan.DrugCompliance,
          ALLERGYHISTORY: this.patientInfo.DrugeValuationPlan.Allergyhistory,
          TREATMENTMEASURES: this.patientInfo.DrugeValuationPlan.TreatMentmeasures,
          DISEASERECOGNITION: this.patientInfo.DrugeValuationPlan.DiseaseRecognition,
          CORRELATIONANALYSIS: this.patientInfo.DrugeValuationPlan.Correlationanalysis,
          SUSPECTEDDRUG: this.patientInfo.DrugeValuationPlan.Suspecteddrugs
        }
      }).then(res => {
        console.log(res)
        if (res === '保存成功') {
          this.$message({
            message: '保存成功',
            type: 'success'
          })
          this.closeDialog()
        } else {
          this.$message({
            message: '保存失败',
            type: 'warning'
          })
          this.closeDialog()
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // close
    closeDialog() {
      this.childOpen = false
      this.queryInfo = {
        patient_id: '',
        visit_id: '',
        inp_no: ''
      }
      // 查询到的信息
      this.patientInfo = {
        DrugeValuationPlan: {
          Concept: '',
          Nutrition: '',
          Hearing: '',
          Language: '',
          Basicdiet: '',
          SelfCareability: '',
          Hobby: '',
          Taboo: '',
          Preference: '',
          TheraPeuticdiet: '',
          Indication: '',
          Dosage: '',
          Attention: '',
          UnUsualReaction: '',
          SelfMedication: '',
          DrugCompliance: '',
          Allergyhistory: '',
          TreatMentmeasures: '',
          Suspecteddrugs: '',
          Correlationanalysis: '',
          DiseaseRecognition: ''
        },
        InpPatData: {}
      }
    }
  }
}
</script>

<style lang="scss" scoped="scoped">
  body{
    background:#e6edf5;
  }
  /deep/.el-radio{
    width: 150px;
  }

  /deep/ .el-scrollbar__wrap {
    overflow-x: hidden;
  }
  .wrapper{
    height: 570px;
    display: flex;
    font-size: 14px;
    flex-direction: column;
    /deep/.card-body{
      font-size: 14px;
    }
    .line{
      display: flex;
      padding-bottom: 5px;
      .line-title{
        width: 110px;
      }
      .line-content {
        margin-left: 20px;
      }
      .line-input{
        display: flex;
        align-items: center;
        width: 240px;
      }
      .line-input-long{
        display: flex;
        align-items: center;
        width: 600px;
      }
      .input-title-long{
        display: flex;
        align-items: center;
        width: 100px;
      }

    }
    .infoline{
      font-size: 14px;
      display: flex;
      justify-content: space-between;
      .fl{
        display: flex;
        padding-bottom: 5px;
        width: 210px;
        .c_tip{
          width: 60px;
          text-align: right;
          /*text-align-last:justify;*/
          /*text-align:justify;*/
        }
        .c_text{
          width: 140px;
          padding-left: 4px;
        }
      }
    }

  }
  /deep/.el-input{
    width:150px;
    height:40px;
    border-radius:4px;
    padding-left:5px;
    font-size: 12px;
  }
  .query{
    width:100%;
    height:100%;
    background:#e6edf5;
    .check{
      font-size:12px;
      display:flex;
      line-height:60px;
      background:#fff;
      text-align:center;
      .c_left{
        width:115px;
        float:left;
      }
      .c_right{
        overflow:hidden;
        color:#636365;
        border-left:1px solid #e6edf5;
        .c_tip{
          display:inline-block;
          width:100px;
          padding-right:10px;
          text-align:right;
        }
        .c_input{
          width:150px;
          height:40px;
          border:1px solid #dcdfe6;
          border-radius:4px;
          padding-left:5px;
        }

        .c_input::-webkit-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-ms-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-moz-input-placeholder {
          color: #dcdfe6;
        }
        .c_search{
          width:100px;
        }
        .c_searchbtn{
          display:inline-block;
          width:42px;
          height:25px;
          margin-left:4px;
          background:#28a4f4;
          color:#fff;
          font-size:12px;
          text-align:center;
          line-height:26px;
          border-radius:6px;
          cursor:pointer;
        }
        .c_checkbox{
          width:230px;
          height:40px;
          display:inline-block;
          margin-left:-12px;
        }
        .btn_clear{
          padding:0;
          width:70px;
          height:40px;
          line-height:40px;
        }
      }
    }
    .list_tip{
      font-size:14px;
      color:#29a4f2;
      padding:10px 18px;
    }
    .table_box{
      padding:0 18px;
    }
  }
  .el-checkbox__label{
    padding-left:5px;
  }
  .el-checkbox{
    margin-right:10px;
  }

</style>
